const canvas_0 = document.querySelector("#canvas_0");
const canvCtx = canvas_0.getContext("2d");
const qwqRange = document.querySelector("#qwqRange");
const qwqButton = document.querySelector("#qwqButton");
var color = "red";
var qwq = "";
qwqButton.addEventListener("click",function(){
    if(color == "red"){
        color = "green";
    }
    else{
        color = "red";
    }
    if(qwq.length <= 6){
        qwq = qwq + document.querySelector("#power").value;
    }
    if(qwq == "114514"){
        document.querySelector("#i0").innerHTML="<img src='./img/beluga.jpg' width='100px' height='100px'>被你发现了";
        setTimeout(function(){
        window.open("https://www.bilibili.com/video/BV1GJ411x7h7/?share_source=copy_web&vd_source=216ca5edeffdd89a002a1833f0a82aa0");
        },1000);
    }
});
var time = function(a){
    switch(a){
        case 2:
            return "²";
            break;
        case 3:
            return "³";
            break;
        case 4:
            return "⁴";
            break;
        case 5:
            return "⁵";
            break;
    }
}
setInterval(function(){
    canvCtx.fillStyle="white";
    canvCtx.fillRect(0, 0, 1000, 1000);
    canvCtx.fillStyle="black";
    canvCtx.fillRect(0,500-qwqRange.value/2,1000,qwqRange.value);
    canvCtx.fillRect(500-qwqRange.value/2,0,qwqRange.value,1000);
    canvCtx.fillStyle = color;
    for(var i = -2000;i <= 2000;i+=0.1){
        canvCtx.fillRect(i-qwqRange.value/2+500, 500-Math.pow(i/100,document.querySelector("#power").value)*100-qwqRange.value/2, qwqRange.value, qwqRange.value);
    }
    document.querySelector("#t0").textContent=qwqRange.value;
    document.querySelector("#t1").textContent=document.querySelector("#power").value;
    document.querySelector("#t2").textContent=color=="red"?"红色":"绿色";
    document.querySelector("#t3").textContent=time(Number(document.querySelector("#power").value));
},16);